<template>
	<div>
		<van-nav-bar
		  :title="title"
		  left-arrow
		  @click-left="onClickLeft"
		>		
		  <van-icon name="arrow-left" slot="left" color="#000" size="20"/>
	    </van-nav-bar>	
	    
	    
	    
	    <van-button type="danger" @click="addOrders">立即购买</van-button>
	</div>	
</template>

<script>
import {getFun} from '@/api/publicFun.js'	 
let publicFun=getFun()	
export default {	
	data() {
       return {
          title:'商品名称',
          comId:'',
          userId:'',
          url6:this.$api+'/marketorderservice/api/v1/market/addOrders', // 生成订单
       }
	},
	methods: {	
       addOrders(){
	        let params={
	    		"goodsId":this.comId,
	    		"userId":this.userId
	        }
	      	let that=this 
	      	this.$Axios2.Post(this.url6,params)
	      	.then(function(res){
	      	   //console.log(res)
		       if(res.responseCode=='300'){		       	 
		       	 alert(res.messageList[0].message)
		       	 return false
		       }else{
		    	 let arg='[{"ordersId":"'+res.ordersId+'"},{"comId":"'+that.comId+'"}]'
                 that.link('/market/order/buy',arg)		       	
		       }
	       })
       }
	},
	mixins:[publicFun],//混入		
	mounted() {
		this.comId=this.$router.currentRoute.query.comId;
		this.userId=this.$router.currentRoute.query.userId;			
	}
}	
</script>

<style scoped="">

</style>